-- time_leap
-- create by panyl
-- 时之刃（技能规则）

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 还原初始血量、魔法值
        assert(target == ME.user, "目前只能是玩家对自己使用！");

        local initAttrib = ME.user.dbase:query("dungeon_init_attrib");
        if not initAttrib then
            return {};
        end

        local hp = initAttrib["curr_hp"] or initAttrib["hp"];
        local mp = initAttrib["curr_mp"] or initAttrib["mp"];
        if not hp or not mp then
            return {};
        end
        
        hp = math.max(hp, ME.user:queryAttrib("hp"));
        mp = math.max(mp, ME.user:queryAttrib("mp"));
        
        target:setHp(hp);
        target:setMp(mp);

        DungeonLogM.addLog(string.format("时之刃效果：hp = %d, mp = %d", hp, mp));

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        return desc;
    end,
};
